package com.zxy.controller;

import com.zxy.result.CommonResult;
import com.zxy.service.StorageService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author: Zxy
 * @description:
 * @date: 2021-08-21 13:49
 */
@RestController
public class StorageController {

    @Resource
    private StorageService storageService;

    /**
     * 调用库存微服务做库存的扣减操作
     *
     * @param productId 商品id
     * @param count     商品的数量
     */
    @PostMapping(value = "/storage/decrease")
    CommonResult decrease(@RequestParam("productId") Long productId,
                          @RequestParam("count") Integer count) {
        storageService.decrease(productId, count);
        return new CommonResult(200,"库存扣减成功");
    }
}
